import { Component } from '@angular/core';
import {  NavController, NavParams,ViewController} from 'ionic-angular';
import { BarcodeScanner } from '@ionic-native/barcode-scanner';
/**
 * Generated class for the ScannerPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */


@Component({
  selector: 'page-scanner',
  templateUrl: 'scanner.html',
})
export class ScannerPage {
  public chooseType='handle';
  public pdfSrc='assets/myFile.pdf';
  public showArr=[
  {
     text:'1.ionic cordova plugin add phonegap-plugin-barcodescanner',
     tips:'安装平台'
    },
    {
      text:'2.cnpm install --save @ionic-native/barcode-scanner',
      tips:'安装依赖'
     },
     {
      text:"3.import { BarcodeScanner } from '@ionic-native/barcode-scanner';",
      tips:'插入依赖'
     }
  ]
  
  constructor(public navCtrl: NavController, 
    public viewCtrl:ViewController,
    public navParams: NavParams,
    public barcodeScanner: BarcodeScanner
    ) {
  }
  dismiss(){
    this.viewCtrl.dismiss();
  }
  openScanner(){
    this.barcodeScanner.scan().then(barcodeData => {
      console.log('Barcode data', barcodeData);
      alert(JSON.stringify(barcodeData))
     }).catch(err => {
      alert(JSON.stringify(err))
     });

  }
  segmentChanged(e){
    console.log(e)
    console.log(this.chooseType)
  }
  ionViewDidLoad() {
    console.log('ionViewDidLoad ScannerPage');
  }

}
